{{ define "content" }}
<article class="fbox">
    <header class="entry-header">
        <h1>登录</h1>
    </header><!-- .entry-header -->

    <div class="entry-content">
        <div id="contact-form-5">
            <form action="/login" method="post"
                class="contact-form commentsblock">
                <div class="grunion-field-wrap grunion-field-name-wrap">
                    <label for="g5-name" class="grunion-field-label">用户名<span>(required)</span></label>
                    <input type="text" name="username" id="username" value="" class="name" required=""
                        aria-required="true">
                </div>
                <div class="grunion-field-wrap grunion-field-name-wrap">
                    <label for="g5-name" class="grunion-field-label">密码<span>(required)</span></label>
                    <input type="password" name="password" id="password" value="" class="password" required=""
                        aria-required="true">
                </div>

                <div class="grunion-field-wrap grunion-field-name-wrap">
                    <label for="g5-name" class="grunion-field-label">验证码<span>(required)</span></label>
                    <input type="text" id="captcha" name="captcha" value="" class="captcha" required=""
                        aria-required="true"> 
                    <input id="keyCaptcha" name="keyCaptcha" style="display:none;" type="text">
                    <img id="imgCaptcha" src="" alt="" style="vertical-align:middle; width:120px; height:50px;">
                </div>
                <p class="contact-submit">
                    <button type="submit" class="pushbutton-wide">提交</button> <input type="hidden"
                        name="contact-form-id" value="5">
                    <input type="hidden" name="action" value="grunion-contact-form">
                    <input type="hidden" name="postid" value="59edecd82be91645212c9981">
                </p>
            </form>
        </div>
    </div><!-- .entry-content -->
</article>
{{ end }}

{{ define "extend_script" }}
<script>
    const refreshCaptcha = function() {
        jQuery.ajax({
            type: 'GET',
            url: '/captcha',
            success: result => {
                if (result.key) {
                    jQuery('#imgCaptcha').attr("src", result.base64image);
                    jQuery('#keyCaptcha').val(result.key)
                }
            },
        });
    };
    refreshCaptcha()
</script>
{{ end }}